package com.ilikesoup.instant.monitor.core;

import lombok.Data;

import java.lang.reflect.Method;

@Data
public class Invocation {
    private MonitorContext context;
    private Object target;
    private Method method;
    private Object[] args;
    private Object retVal;

    public Invocation(MonitorContext context, Object target, Method method, Object[] args) {
        this.context = context;
        this.target = target;
        this.method = method;
        this.args = args;
    }

    public Invocation(MonitorContext context, Object target, Method method, Object[] args, Object retVal) {
        this.context = context;
        this.target = target;
        this.method = method;
        this.args = args;
        this.retVal = retVal;
    }

    public Object serialize(Object source) {
        return context.serialize(source);
    }

    public Object getSerializedArgs() {
        return serialize(args);
    }

    public Object getSerializedRetVal() {
        return serialize(retVal);
    }

    public Object getSerializedTarget() {
        return serialize(target);
    }

    public String getMethodName() {
        return method.getName();
    }

}
